You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
505 B
16 lines
505 B
import { delCache } from "#server/utils/context";
|
|
import { deleteTool, getToolById } from "../../service/tool";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const id = getRouterParam(event, "id");
|
|
if (!id) return R.throwError(400, "Missing id", null);
|
|
|
|
const existing = await getToolById(id);
|
|
if (!existing) return R.throwError(404, "Tool not found", null);
|
|
|
|
await deleteTool(id);
|
|
await delCache(`tool:${id}`);
|
|
await delCache("tools:list");
|
|
|
|
return R.success(null);
|
|
});
|
|
|